home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2005 February / WN_129_CD.iso / Windows / Extensions Firefox / Extension Uninstaller / extuninstallapiFr-02.xpi / extuninstallapi.jar / content / logger.js < prev    next >
Encoding:
JavaScript  |  2004-06-07  |  2.2 KB  |  106 lines

  1.  
  2. //Logger Object
  3. function ExtUninstallLogger(){
  4.     
  5.     // Constants
  6.         // Actions
  7.         this.READ_ACTION        = 20;
  8.         this.WRITE_ACTION        = 21;
  9.         this.ADD_ACTION            = 22;
  10.         this.REMOVE_ACTION        = 23;
  11.         this.EDIT_ACTION        = 24;
  12.         this.EXECUTE_ACTION        = 25;
  13.         this.UNINSTALL_ACTION    = 26;
  14.         
  15.         // Status
  16.         this.SUCCESS_STATUS    = 30;
  17.         this.EMPTY_STATUS    = 31;
  18.         this.FAIL_STATUS    = 32;
  19.         this.WARN_STATUS    = 33;
  20.     
  21.     this.type        = "logger";
  22.     this.logs         = new Array();
  23.     
  24.     // Functions
  25.     this.addLog = extuninstall_log_addLog;
  26.     this.hasError = extuninstall_log_hasError;
  27.     this.hasWarning = extuninstall_log_hasWarning;
  28. }
  29.  
  30.  
  31. // Add Log Object
  32. function extuninstall_log_addLog(oLogItem){
  33.     this.logs[this.logs.length] = oLogItem;
  34.     
  35.     return oLogItem;
  36. }
  37.  
  38. // Is there any log item with Errors or Warnings
  39. function extuninstall_log_hasError(aLogs, status){
  40.     
  41.     // Fill Status
  42.     if(status == null){
  43.         status = (new ExtUninstallLogger()).FAIL_STATUS;
  44.     }
  45.         
  46.     // Fill aLogs
  47.     if(aLogs == null && this.type == "logger"){
  48.         aLogs = this.logs;
  49.     }
  50.     else if(aLogs == null && this.type == "logitem"){
  51.         aLogs = this.children;
  52.         
  53.         if(this.status == status)
  54.             return true;
  55.     }
  56.     else if(aLogs == null){
  57.         return false;
  58.     }
  59.     
  60.     // Loop through logs
  61.     for(var i = 0; i < aLogs.length; i++){
  62.                 
  63.         if(aLogs[i].status == status){
  64.             return true;
  65.         }
  66.         else if(aLogs[i].children.length > 0){
  67.             if(this.hasError(aLogs[i].children, status))
  68.                 return true;
  69.         }
  70.     }
  71.     
  72.     return false;
  73. }
  74.  
  75. function extuninstall_log_hasWarning(){
  76.     if(this.type == "logger"){
  77.         return this.hasError(this.logs, this.WARN_STATUS);
  78.     }
  79.     else if(this.type == "logitem"){
  80.         return this.hasError(this.children, (new ExtUninstallLogger()).WARN_STATUS);
  81.     }
  82. }
  83.  
  84.  
  85. // Log Item
  86. function ExtuninstallLogItem(iAction, iStatus, sMessage, iErrorCode, sError){
  87.     this.type        = "logitem";
  88.     this.action     = iAction;
  89.     this.status     = iStatus;
  90.     this.message    = sMessage;
  91.     this.errorCode     = iErrorCode;
  92.     this.errorMsg     = sError;
  93.     this.children    = new Array();
  94.     
  95.     this.addChild = extuninstall_log_addChild;
  96.     this.hasError = extuninstall_log_hasError;
  97.     this.hasWarning = extuninstall_log_hasWarning;
  98. }
  99.  
  100. // Add log to log
  101. function extuninstall_log_addChild(oLog){
  102.     this.children[this.children.length] = oLog;
  103.     
  104.     return oLog;
  105. }
  106.